import numpy as np
import matplotlib.pyplot as plt

# 给定的点集
points = np.array([
(114.290774,30.582743)
,(114.264954,30.603727)
,(114.291167,30.583053)
,(114.289372,30.581370)
,(114.294876,30.594710)
,(114.279152,30.577272)
,(114.279101,30.577162)
,(114.295168,30.593389)
,(114.276543,30.576963)
,(114.282424,30.577225)
,(114.284701,30.607250)
,(114.285278,30.607086)
,(114.282425,30.577107)
,(114.267956,30.578334)
,(114.266550,30.606136)
,(114.295692,30.588768)
,(114.295736,30.588725)
,(114.276642,30.609140)
,(114.295222,30.598314)
,(114.257804,30.591326)
,(114.280588,30.576043)
,(114.292942,30.582417)
,(114.277866,30.609556)
,(114.277048,30.575558)
,(114.295062,30.600001)
,(114.293222,30.591355)
,(114.291278,30.585793)
,(114.281970,30.605884)
,(114.282162,30.605904)
,(114.260861,30.591677)
,(114.292481,30.597467)
,(114.262369,30.586348)
,(114.272755,30.606313)
,(114.290739,30.584074)
,(114.281810,30.578650)
,(114.275858,30.607172)
,(114.262595,30.600168)
,(114.292664,30.598663)
,(114.280300,30.578033)
,(114.275320,30.607304)
,(114.294374,30.592547)
,(114.275280,30.607335)
,(114.262943,30.584171)
,(114.270099,30.606141)
,(114.259837,30.591596)
,(114.259999,30.590279)
,(114.275848,30.607586)
,(114.259722,30.591372)
,(114.262158,30.584735)
,(114.292059,30.600754)
,(114.287957,30.600103)
,(114.281296,30.580976)
,(114.269028,30.602774)
,(114.283250,30.581326)
,(114.285029,30.581981)
,(114.289520,30.585602)
,(114.262883,30.589195)
,(114.288212,30.601105)
,(114.290080,30.586090)
,(114.292385,30.591015)
,(114.283448,30.604689)
,(114.264363,30.585099)
,(114.263114,30.586520)
,(114.290840,30.585927)
,(114.291220,30.586504)
,(114.290873,30.585918)
,(114.288300,30.582970)
,(114.292888,30.593743)
,(114.292216,30.596750)
,(114.291672,30.598159)
,(114.290379,30.600190)
,(114.283999,30.580196)
,(114.292423,30.596650)
,(114.291073,30.585646)
,(114.292713,30.588973)
,(114.267651,30.592817)
,(114.273015,30.600042)
,(114.287163,30.593047)
,(114.287521,30.591133)
,(114.277461,30.601832)
,(114.286364,30.597694)
,(114.286836,30.597207)
,(114.266147,30.589399)
,(114.266061,30.589276)
,(114.267638,30.585831)
,(114.281782,30.582693)
,(114.289733,30.594159)
,(114.273800,30.603134)
,(114.289553,30.595947)
,(114.282058,30.582049)
,(114.282807,30.582267)
,(114.274715,30.581319)
,(114.273814,30.603745)
,(114.271004,30.603001)
,(114.290174,30.589020)
,(114.288007,30.599844)
,(114.284050,30.582313)
,(114.290925,30.591648)
,(114.264630,30.597587)
,(114.283002,30.581747)
,(114.276286,30.591012)
,(114.274853,30.591239)
,(114.277998,30.590115)
,(114.276726,30.595661)
,(114.277879,30.589474)
,(114.273483,30.593228)
,(114.276756,30.588540)
,(114.280217,30.595978)
,(114.277291,30.588265)
,(114.272032,30.593657)
,(114.277200,30.597572)
,(114.271574,30.593994)
,(114.276551,30.597574)
,(114.271491,30.594132)
,(114.279980,30.587836)
,(114.282372,30.588815)
,(114.283275,30.595674)
,(114.270578,30.595157)
,(114.269966,30.591105)
,(114.283449,30.589183)
,(114.269700,30.591300)
,(114.270015,30.594929)
,(114.268576,30.592237)
,(114.285531,30.594489)
,(114.281594,30.585954)
,(114.258361,30.586910)
,(114.257145,30.590174)
,(114.257082,30.590233)
,(114.262673,30.604595)
,(114.267875,30.578485)
,(114.258727,30.584514)
,(114.264061,30.605810)
,(114.256289,30.587866)
,(114.256111,30.587592)
,(114.262822,30.606014)
,(114.267316,30.577228)
,(114.257442,30.583271)
,(114.258530,30.581591)
,(114.274835,30.610550)
,(114.270327,30.610883)
,(114.268950,30.611457)
,(114.278209,30.611471)
,(114.280864,30.610731)
,(114.263570,30.609800)
,(114.268137,30.581178)
,(114.285801,30.609183)
,(114.276950,30.612803)
,(114.260368,30.608623)
,(114.273358,30.613412)
,(114.284327,30.610954)
,(114.288338,30.585220)
,(114.255131,30.603690)
,(114.263480,30.611760)
,(114.274864,30.614094)
,(114.285859,30.610674)
,(114.289809,30.607732)
,(114.289955,30.607635)
])

# 分离x和y坐标
x = points[:, 0]
y = points[:, 1]

# 计算中心点坐标
center_x = np.mean(x)
center_y = np.mean(y)

# 计算半径
radius = np.sqrt(((x - center_x) ** 2 + (y - center_y) ** 2)).max()  # 使用最大距离作为半径

# 自动调整坐标轴范围
ax_range = radius * 1.1  # 将坐标轴范围设为半径的1.1倍
plt.figure(figsize=(8, 8))  # 可以调整图形大小
plt.scatter(x, y, color='blue', label='快递网点')

# 绘制圆心点
plt.scatter(center_x, center_y, color='black', label='Circle center')

# 绘制圆
theta = np.linspace(0, 2 * np.pi, 100)
x_fit = center_x + radius * np.cos(theta)
y_fit = center_y + radius * np.sin(theta)
plt.plot(x_fit, y_fit, 'r--', label='Circle')

# 设置三个点
red_point =(114.277158,30.592578)# 红色点坐标
green_point =(114.273599,30.596733)# 绿色点坐标
yellow_point =(114.273801,30.59283)# 黄色点坐标

# 计算距离
distances = {
    'red': np.linalg.norm(np.array(red_point) - np.array([center_x, center_y])),
    'green': np.linalg.norm(np.array(green_point) - np.array([center_x, center_y])),
    'yellow': np.linalg.norm(np.array(yellow_point) - np.array([center_x, center_y]))
}

# 绘制三个点
plt.scatter(red_point[0], red_point[1], color='red', label='中诚大厦')
plt.scatter(green_point[0], green_point[1], color='green', label='武银大厦')
plt.scatter(yellow_point[0], yellow_point[1], color='yellow', label='良友大厦')

# 设置坐标轴范围
plt.xlim(center_x - ax_range, center_x + ax_range)
plt.ylim(center_y - ax_range, center_y + ax_range)

# 显示图例
plt.legend()

# 显示图形
plt.show()

# 打印三个点到圆心的距离
print("Distances from the center of the circle to the points:")
for color, distance in distances.items():
    print(f"{color.capitalize()} point: {distance:.2f}")